package com.ttg.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;


public enum ValueNullAllowEnum {


    /**
     * 正常
     */
    NOT_ALLOW(0, "不允许不入库"),
    /**
     * 冻结
     */
    ALLOW(1, "允许入库");

    @EnumValue
    @JsonValue
    private Integer value;
    private String desc;

    ValueNullAllowEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, ValueNullAllowEnum> VALUES = new HashMap<>();

    static {
        for (final ValueNullAllowEnum type : ValueNullAllowEnum.values()) {
            ValueNullAllowEnum.VALUES.put(type.getValue(), type);
        }
    }

    @JsonCreator
    public static ValueNullAllowEnum of(Integer code) {
        return ValueNullAllowEnum.VALUES.get(code);
    }
}
